<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>主要的</title>
</head>

<body>
<?php
require 'include.php';
require 'config.php';
#wt_SQL::connect($host,$user,$passw,$db);
//$rs = mysql_query("SHOW TABLES");
$rss = "http://hi.baidu.com/zhubaining/rss";//源

#读取博文信息
$post = wt_xml::readRSS($rss);
$blog = wt_xml::readInfo($rss);//读取博客信息
print_r ($post);
//echo $arr["feed_rss"];
/*
$sql = "SELECT Blog_Feed FROM `blog_info` WHERE Blog_Feed = '" . $post["feed_rss"] . "'";//查看有没有此博客记录
//$result_num = mysql_query($sql);
#获得指定源更新时间
function post_PubDate($post)
{
	$sql = "SELECT `Ppost_PubDate` FROM post_into WHERE `Post_Feed` = '" . $post['feed_rss'] ."' ORDER BY Pid DESC LIMIT 1";//获得最后发表博文的时间。
	$arr = wt_SQL::get_one($sql);
	return $arr;
}
//print_r(post_PubDate($post));
#-----获得未读博文
#-----有未读博文返回博文更新时间，没有就返回false;
function new_post($post)
{
	//$post['pubDate']
	$new_post = array();
	foreach ($post as $key => $value)
	{
		//echo $post[$key]['pubDate'];
		if ($post[$key]['pubDate'] > post_PubDate($post))
		{
			$new_post = $post[$key]['pubDate'];	
		}
	}
	if(empty($new_post))
	{
		return false;
	}
	else
	{
		return $new_post;
	}	
}
/*
$nwspost = new_post($post);
if(new_post($post))
{
	echo '有';	
}
else
{
	echo '全都看过啦';	
}*/
//if(new_post($post))

#加入源成或者文章
/*

	if(wt_SQL::query_num($result_num))
	{
		//print_r ($post);
		$t = count($post) - 2;//整个博文条数[数组下标]
		//$post_sql = "INSERT INTO `post_into` (`Pid`, `Post_Title`, `Post_Link`, `Ppost_PubDate`, `Post_Creator`, `Post_Content`, `Post_Comments`, `Post_State`, `Post_Feed`) VALUES (NULL,'" . $post[0]['title'] . "','" . $post[0]['link'] . "','" . wt_time::Str2time($post[0]['pubDate']) . "','" . $post[0]['dc_creator'] . "','" . $post[0]['content_encoded'] . "','" . $post[0]['slash_comments'] . "','" . '1' . "','" . $post['feed_rss'] . "')";
		//echo $post_sql;
		//echo $post['feed_rss'];
		$sql_postnum = "SELECT Pid FROM `post_into` WHERE Post_Feed = '" . $post['feed_rss'] . "'";//获得相应RSS下的所有文章ID
		$res_postnum = mysql_query($sql_postnum);//获得相应RSS下的所有文章ID
		$rssnum = wt_SQL::query_num($res_postnum);//获得相应RSS下的所有文章总数
		$sql_post_update = "SELECT `Ppost_PubDate` FROM post_into WHERE `Post_Feed` = '" . $post['feed_rss'] ."' ORDER BY Pid DESC LIMIT 1";//获得最后发表博文的时间。
		//$res_update = mysql_query($sql_update);//对比博文最后更新时间
		$res_post_update = mysql_query($sql_post_update);
		if(wt_SQL::query_num($res_post_update))
		{}
		else
		{
			echo '该源没有发表博文!';		
		}
	
		//echo wt_SQL::query_num($res_update);
		for(;$t >= 0;$t--)
		{
			//echo ($post[$i]);
			//$sql_update = "SELECT '2010-04-21 02:03:39' > '2010-05-13 04:55:54'";
			$post_sql = "INSERT INTO `post_into` (`Pid`, `Post_Title`, `Post_Link`, `Ppost_PubDate`, `Post_Creator`, `Post_Content`, `Post_Comments`, `Post_State`, `Post_Feed`) VALUES (NULL,'" . $post[$t]['title'] . "','" . $post[$t]['link'] . "','" . $post[$t]['pubDate'] . "','" . $post[$t]['dc_creator'] . "','" . $post[$t]['content_encoded'] . "','" . $post[$t]['slash_comments'] . "','" . '1' . "','" . $post['feed_rss'] . "')";
			//echo $post_sql;
			mysql_query($post_sql);
			//echo "\n";
		
			//"INSERT INTO `feed`.`post_into` (`Pid`, `Post_Title`, `Post_Link`, `Ppost_PubDate`, `Post_Creator`, `Post_Content`, `Post_Comments`, `Post_State`, `Post_Feed`) VALUES (NULL, \'tile\', \'http://\', \'2010-05-03 17:45:51\', \'wangtao\', \'hohohohhohoohohohohhohoohohohohhohoohohohohhohoohohohohhohoohohohohhohoohohohohhohoo\', \'0\', \'1\', \'http://file.xml\');";
		 
		}
	}
	else
	{
		echo "还没加入此源哦！！";
		//print_r($blog);
		$blog_info_sql = "INSERT INTO `blog_info` (`BID` ,`Blog_Title` ,`Blog_Link` ,`Blog_Descripton` ,`Blog_LastBuildDate` ,`Blog_Feed` ,`Blog_State`) VALUES (NULL,'" . $blog['title'] . "','" . $blog['link'] . "','" . $blog['description'] . "','" . $blog['lastBuildDate'] . "','" . $blog['feed'] . "','" . "1" . "')";
		mysql_query($blog_info_sql);//加入此源
		#$result = mysql_query($blog_info_sql);
		#echo wt_SQL::query_num($result,1);
	}
*/
?>
</body>
</html>